package farmer.core;

import java.awt.Graphics2D;

public class Building extends Basic implements Drawable, Updateable{
	
	public int woodCost = 0;
	public int rockCost = 0;

	protected int posX;
	protected int posY;
	protected int size;
	protected boolean inConstruction = true;
	protected boolean isBuilding = false;
	protected boolean isSelected = false;
	protected double constructionPercentage = 20;
	protected double constructionSpeed = 0.01;
	
	public Building(int x, int y){
		this.posX = x;
		this.posY = y;
	}
	
	public void setSelected(boolean value){
		isSelected = value;
	}
	
	public boolean contains(int x, int y){
		if((posX <=x && posX+size > x) && (posY <= y && posY+size > y)){
			return true;
		}
		return false;
	}
	
	public int getX(){
		return posX;
	}
	public int getY(){
		return posY;
	}
	public int getCellX(){
		return posX;
	}
	public int getCellY(){
		return posY;
	}
	public int getSize(){
		return size;
	}
	public void beginConstruction(){
		isBuilding = true;
	}
	public int getWoodCost(){
		return woodCost;
	}
	public int getRockCost(){
		return rockCost;
	}
	
	
	@Override
	public void update(int deltaTime) {
		if(isBuilding){
			constructionPercentage += constructionSpeed*deltaTime;
			if(constructionPercentage >= 100){
				isBuilding = false;
				inConstruction = false;
			}
		}
	}

	@Override
	public void draw(Graphics2D g) {
		// TODO Auto-generated method stub
		
	}

}
